package com.changgou.system.goods.service.impl;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.changgou.goods.pojo.Spec;
import com.changgou.system.goods.dao.SpecMapper;
import com.changgou.system.goods.service.SpecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
@Service
public class SpecServiceImpl extends ServiceImpl<SpecMapper, Spec> implements SpecService {
    @Autowired
    private SpecMapper specMapper;
    @Override
    public List<Map<String, Object>> findListByCategoryName(String category) {
        List<Map<String,Object>> specList =specMapper.findListByCategoryName(category);
        specList.forEach(s -> s.put("options",StrUtil.split(Convert.toStr(s.get("options")), ",")));
        return specList;
    }
}
